Fixed several assertTrue() that were intended to be assertEqual().#8191
Merged
Conversation
| result = f(self.wrap(1), self.wrap("x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0)) | ||
| self.assertEqual(result, 139) | ||
| self.assertTrue(type(result), int) | ||
| self.assertEqual(type(result), int) |
| message = "FilterTests.test_always" | ||
| self.module.warn(message, UserWarning) | ||
| self.assertTrue(message, w[-1].message) | ||
| self.assertEqual(message, w[-1].message.args[0]) |
Member
There was a problem hiding this comment.
There are other flaws in this test, due to which the second assertion doesn't have effect. Rewrite the test as:
def test_always(self):
with original_warnings.catch_warnings(record=True,
module=self.module) as w:
self.module.resetwarnings()
self.module.filterwarnings("always", category=UserWarning)
message = "FilterTests.test_always"
def f():
self.module.warn(message, UserWarning)
f()
self.assertEqual(len(w), 1)
self.assertEqual(w[-1].message.args[0], message)
f()
self.assertEqual(len(w), 2)
self.assertEqual(w[-1].message.args[0], message)
Member
|
Good catch! |
serhiy-storchaka
approved these changes
Jul 9, 2018
Contributor
|
Thanks @sir-sigurd for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7. |
|
GH-8200 is a backport of this pull request to the 3.7 branch. |
Contributor
|
Sorry, @sir-sigurd and @serhiy-storchaka, I could not cleanly backport this to |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jul 9, 2018
…ythonGH-8191) Fixed also testing the "always" warning filter. (cherry picked from commit b796e7d) Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
|
GH-8201 is a backport of this pull request to the 3.6 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jul 9, 2018
…ythonGH-8191) Fixed also testing the "always" warning filter. (cherry picked from commit b796e7d) Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
serhiy-storchaka
pushed a commit
to serhiy-storchaka/cpython
that referenced
this pull request
Jul 9, 2018
…(). (pythonGH-8191) Fixed also testing the "always" warning filter.. (cherry picked from commit b796e7d) Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
|
GH-8202 is a backport of this pull request to the 2.7 branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.